package com.shenzhen.horselive.network;


import com.shenzhen.horselive.api.ApiException;
import com.shenzhen.horselive.api.response.ApiResponse;
import io.reactivex.functions.Function;


public class HttpResultFunc<T> implements Function<ApiResponse<T>, ApiResponse<T>> {
    @Override
    public ApiResponse<T> apply(ApiResponse<T> apiResponse) {


        if (!apiResponse.isSuccess()) {
            throw new ApiException(apiResponse.getCode(), apiResponse.getMessage());
        }

        return apiResponse;
    }
}